//
//  LiuyanViewController.m
//  ppkc2016
//
//  Created by Laura on 2017/3/17.
//  Copyright © 2017年 拼凑的断音. All rights reserved.
//

#import "LiuyanViewController.h"
#import "XVVTextViewWithPlaceholder.h"
#import "XXTool.h"
#import "XMLVisitorMessageModel.h"

@interface LiuyanViewController ()

@property (nonatomic,strong) UIBarButtonItem *barRightButton;
@property (nonatomic,strong) UIButton *testButton;
@property (nonatomic,strong) XVVTextViewWithPlaceholder *inputRemarks;

@property(nonatomic,strong) NSString * url;

@end

@implementation LiuyanViewController

-(UIBarButtonItem*)barRightButton
{
    if (_barRightButton==nil)
    {
        _testButton=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 50)];
        [_testButton addTarget:self action:@selector(clickTijiao) forControlEvents:UIControlEventTouchUpInside];
        [_testButton setTitle:NSLocalizedString(@"提交", nil ) forState:UIControlStateNormal];
        [_testButton setTitleColor:[XXTool colorWithProject] forState:(UIControlStateNormal)];
        _barRightButton = [[UIBarButtonItem alloc] initWithCustomView:_testButton];
    }
    return _barRightButton;
}

-(XVVTextViewWithPlaceholder*)inputRemarks
{
    if (_inputRemarks==nil)
    {
        _inputRemarks = [[XVVTextViewWithPlaceholder alloc] init];
        _inputRemarks.textFont = [XXTool systemFontOfSize:16];
        _inputRemarks.placeholder_textColor = [XXTool colorWithHexString:@"8B8B8B"];
        _inputRemarks.placeholder = NSLocalizedString(@"需要发送的留言信息", nil);
        _inputRemarks.backgroundColor =[UIColor whiteColor];
        [self.view addSubview:_inputRemarks];
    }
    return _inputRemarks;
}


-(void)initUI
{
    [self.navigationItem setTitle:NSLocalizedString(@"预约展商", nil)];
    [self.navigationItem setRightBarButtonItem:self.barRightButton];
    [self inputRemarks];
    
    
}

-(void)refreshLayout:(CGRect)frame{
    
    _inputRemarks.frame = CGRectMake(0
                                     , 30
                                     , frame.size.width
                                     , 100);
    
}

/**
 *  提交留言
 */
-(void) clickTijiao{
    if(_useType == XVCVisitor){
        _url=@"editMessage_gz_2017_";
    }else{
       _url=@"editMessage_zs_2017_";
    }
    
    [XMLVisitorMessageModel requestVisitorSendLiuyanType:_inputRemarks.inputTextString orderId:_liuyan_id Url:_url completion:^(BOOL isSuccess){
        if(isSuccess){
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}

// 从 观众信息 的cell中转到留言
+(void) pushVisitorInfoWithSourceId:(UIViewController*) sourceId liuyan_id:(NSString*) lid
     Type:(NSInteger) type{
    LiuyanViewController *liu=[[LiuyanViewController alloc]init];
    liu.liuyan_id=lid;
    NSLog(@"传过来的ID是。%@",lid);
    if (sourceId)
    {
        [sourceId.navigationController pushViewController:liu animated:YES];
    }
}

+(void)pushVistorLiuyanDetailWithSourceVC:(UIViewController *)sourceId apmentID:(NSString *)apId Type:(NSInteger) type{
    LiuyanViewController *liu=[[LiuyanViewController alloc]init];
    liu.liuyan_id=apId;
    liu.useType=type;
    NSLog(@"传过来的ID是。%@",apId);
    if (sourceId)
    {
        [sourceId.navigationController pushViewController:liu animated:YES];
    }

}

@end
